﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ADTest
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }

        private void getUsersInGroupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Ko2.Sys.AD o = new Ko2.Sys.AD();
            DataTable tbl = new DataTable("users");
            //o.GetUsersInGroup(ref tbl, "ACS_APP20_OLAP");
            o.GetUsersInGroup(ref tbl, "Domain Users");
            gv.DataSource = tbl;
        }

        private void getUsersInOfficeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Ko2.Sys.AD o = new Ko2.Sys.AD();
            DataTable tbl = new DataTable("users");
            o.GetUsersInOffice(tbUser: ref tbl, OfficeName: "Румянцево", IsOnlyActived: true, IsExtProp: true);
            //o.GetUsersInNotOffice(ref tbl, "Румянцево");
            gv.DataSource = tbl;
        }

        private void allToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Exception ret = null;
            DataTable tbl = null;
            List<string> errList = new List<string>();
            Ko2.Web.Utils.WS_Helper hlp =
                new Ko2.Web.Utils.WS_Helper();
            ret = hlp.GetADUsersListALL(ref tbl, ref errList);
            if (ret == null)
                gv.DataSource = tbl;
            else
                gv.DataSource = null;
        }

        private void fromWSInOfficeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Exception ret = null;
            DataTable tbl = null;
            List<string> errList = new List<string>();
            Ko2.Web.Utils.WS_Helper hlp =
                new Ko2.Web.Utils.WS_Helper();
            ret = hlp.GetADUsersListInOffice(ref tbl, ref errList);
            if (ret == null)
                gv.DataSource = tbl;
            else
                gv.DataSource = null;
        }

        private void fromWSNotInOfficeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Exception ret = null;
            DataTable tbl = null;
            List<string> errList = new List<string>();
            Ko2.Web.Utils.WS_Helper hlp =
                new Ko2.Web.Utils.WS_Helper();
            ret = hlp.GetADUsersListInNotOffice(ref tbl, ref errList);
            if (ret == null)
                gv.DataSource = tbl;
            else
                gv.DataSource = null;
        }

    }
}
